#include "buzzer.h"


void buzzer_init(void)
{
    GpioInit();
    // 蜂鸣器引脚 设置为 PWM功能
    IoSetFunc(WIFI_IOT_IO_NAME_GPIO_8, WIFI_IOT_IO_FUNC_GPIO_8_PWM1_OUT);
    PwmInit(WIFI_IOT_PWM_PORT_PWM1);
    hi_pwm_set_clock(PWM_CLK_XTAL);
    PwmStop(WIFI_IOT_PWM_PORT_PWM1);
}

void buzzer_on(void)
{
    PwmStart(WIFI_IOT_PWM_PORT_PWM1, 20*1000, 40*1000);
}
void buzzer_off(void)
{
    PwmStop(WIFI_IOT_PWM_PORT_PWM1);
}